﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace DisplayBoardInfoClient
{
    class DayOpenList
    {
        public SortedList<int, OpenHours> list = new SortedList<int,OpenHours>();

        public DayOpenList()
        {

        }
        public void addAdmission(XmlElement admission)
        {
            string doc = admission.GetElementsByTagName("name")[0].InnerText.Substring(0, 1) + "." + admission.GetElementsByTagName("surname")[0].InnerText;
            TimeSpan openHour = new TimeSpan(Int32.Parse(admission.GetElementsByTagName("openHour")[0].InnerText.Substring(11, 2)), Int32.Parse(admission.GetElementsByTagName("openHour")[0].InnerText.Substring(14, 2)), 0);
            TimeSpan closeHour = new TimeSpan(Int32.Parse(admission.GetElementsByTagName("closeHour")[0].InnerText.Substring(11, 2)), Int32.Parse(admission.GetElementsByTagName("closeHour")[0].InnerText.Substring(14, 2)), 0);
            list.Add(openHour.Hours * 100 + openHour.Minutes, new OpenHours(openHour, closeHour, doc));
        }
        public class OpenHours 
        {
            TimeSpan openHour, closeHour;
            string doctorShort;
            public OpenHours(TimeSpan open, TimeSpan close,string doctor){
                openHour=open;
                closeHour=close;
                doctorShort=doctor;
            }
            public string ToString()
            {
                return "" + openHour.Hours.ToString("00") + ":" + openHour.Minutes.ToString("00") + "-" + closeHour.Hours.ToString("00") + ":" + closeHour.Minutes.ToString("00") + "  " + doctorShort;
            }
        }
        
    }
}
